/*
 * @Author: Jimmy
 * @LastModifiedBy: Jimmy
 * @Date: 2024-03-07 20:52:59
 * @LastEditTime: 2024-12-14 13:48:33
 * @FilePath: /monitor_belt/src/components/table_search/index.tsx
 */
import { Button, Flex } from 'antd'
import { ReloadOutlined, PlusCircleOutlined } from '@ant-design/icons';
import styles from './index.module.scss'
import SearchItem from '../search_item';

export default function TableSearch(props: any) {
    let {
        isExtra = true,
        isSearch = true,
        addText = '新增',
        deleteText = '删除',
        extraComponent,
        isDelete = true,
        deletePerm = 0,
        children,
    } = props;
    return (
        <Flex gap={20} className={`${styles.table_search_frame}`}>
            {
                isExtra && <Flex gap={12} className={`${!isSearch && styles.search_bottom} search_footer`}>
                    {
                        extraComponent ? extraComponent : (
                            <>
                                <Button type="primary" icon={<PlusCircleOutlined />} onClick={() => props.add()}>{addText}</Button>
                                {
                                    isDelete && <SearchItem><Button className={`${styles.btn}`} type="primary" onClick={() => props.delete()} disabled={!deletePerm}>{deleteText}</Button></SearchItem>
                                }
                            </>
                        )
                    }
                </Flex>
            }
            <Flex wrap='wrap' flex={1} gap={20} justify='start' className={`${styles.search_header}`}>
                {
                    isSearch && (
                        <>
                            {children}
                            <SearchItem>
                                <Button type='primary' className={`${styles.btn} search_btn`} onClick={() => props.search()}>搜索</Button>
                            </SearchItem>
                            <SearchItem>
                                <Button type='primary' ghost className={`${styles.btn}`} onClick={() => props.reset()}><ReloadOutlined /></Button>
                            </SearchItem>
                        </>
                    )
                }
            </Flex>

        </Flex>
    )
}
